@charset "UTF-8";.ai1wm-button-group{border:2px solid #27ae60;background-color:transparent;color:#27ae60;border-radius:5px;cursor:pointer;text-transform:uppercase;font-weight:600;transition:background-color .2s ease-out;display:inline-block;text-align:right}.ai1wm-button-group.ai1wm-button-export,.ai1wm-button-group.ai1wm-button-import{box-sizing:content-box}.ai1wm-button-group.ai1wm-button-export.ai1wm-open>.ai1wm-dropdown-menu{height:448px;border-top:1px solid #27ae60}.ai1wm-button-group.ai1wm-button-import.ai1wm-open>.ai1wm-dropdown-menu{height:476px;border-top:1px solid #27ae60}.ai1wm-button-group .ai1wm-button-main{position:relative;padding:6px 25px 6px 50px;box-sizing:content-box}.ai1wm-button-group .ai1wm-dropdown-menu{height:0;overflow:hidden;transition:height .2s cubic-bezier(.19,1,.22,1);border-top:none}.ai1wm-dropdown-menu{list-style:none}.ai1wm-dropdown-menu,.ai1wm-dropdown-menu li{margin:0!important;padding:0}.ai1wm-dropdown-menu li a,.ai1wm-dropdown-menu li a:visited{display:block;padding:5px 26px;text-decoration:none;color:#27ae60;text-align:right;box-sizing:content-box}.ai1wm-dropdown-menu li a:hover,.ai1wm-dropdown-menu li a:visited:hover{text-decoration:none;color:#111}.ai1mw-lines{position:absolute;width:12px;height:10px;top:9px;left:20px}.ai1wm-line{position:absolute;width:100%;height:2px;margin:auto;background:#27ae60;transition:all .2s ease-in-out}.ai1wm-line-first{top:0;right:0}div.ai1wm-open .ai1wm-line-first,div.ai1wm-open .ai1wm-line-third{top:50%}.ai1wm-line-second{top:50%;right:0}.ai1wm-line-third{top:100%;right:0}.ai1wm-button-blue,.ai1wm-button-gray,.ai1wm-button-green,.ai1wm-button-green-small,.ai1wm-button-red{display:inline-block;border:2px solid #95a5a6;background-color:transparent;color:#95a5a6;border-radius:5px;cursor:pointer;padding:5px 26px 5px 25px;text-transform:uppercase;font-weight:600;outline:0;transition:background-color .2s ease-out;text-decoration:none}.ai1wm-button-gray:hover{background-color:#95a5a6;color:#fff}.ai1wm-button-blue,.ai1wm-button-green,.ai1wm-button-green-small,.ai1wm-button-red{border:2px solid #27ae60;color:#27ae60}.ai1wm-button-green:hover{background-color:#27ae60;color:#fff}.ai1wm-button-blue,.ai1wm-button-green-small,.ai1wm-button-red{border:2px solid #6eb649;color:#6eb649}.ai1wm-button-green-small:hover{background-color:#6eb649;color:#fff}.ai1wm-button-blue,.ai1wm-button-red{border:2px solid #00aff0;color:#00aff0}.ai1wm-button-blue:hover{background-color:#00aff0;color:#fff}.ai1wm-button-red{border:2px solid #e74c3c;color:#e74c3c}.ai1wm-button-red:hover{background-color:#e74c3c;color:#fff}.ai1wm-button-blue[disabled=disabled],.ai1wm-button-green-small[disabled=disabled],.ai1wm-button-green[disabled=disabled],.ai1wm-button-red[disabled=disabled]{opacity:.6;cursor:default}.ai1wm-button-blue[disabled=disabled]:hover{color:#00aff0}.ai1wm-button-red[disabled=disabled]:hover{color:#e74c3c}.ai1wm-button-green[disabled=disabled]:hover{color:#27ae60}.ai1wm-button-blue[disabled=disabled]:hover,.ai1wm-button-green-small[disabled=disabled]:hover,.ai1wm-button-green[disabled=disabled]:hover,.ai1wm-button-red[disabled=disabled]:hover{background:100% 0}.ai1wm-message-close-button{position:absolute;left:10px;top:6px;text-decoration:none;font-size:10px}input[type=radio].ai1wm-flat-radio-button{display:none}input[type=radio].ai1wm-flat-radio-button+a i,input[type=radio].ai1wm-flat-radio-button+label i{vertical-align:middle;float:right;width:25px;height:25px;border-radius:50%;background:100% 0;border:2px solid #ccc;content:" ";cursor:pointer;position:relative;box-sizing:content-box}input[type=radio].ai1wm-flat-radio-button:checked+a i,input[type=radio].ai1wm-flat-radio-button:checked+label i{background-color:#d9d9d9;border-color:#6f6f6f}.ai1wm-icon-update{font-size:13px;padding:0;margin:0;font-weight:400}.ai1wm-icon-update:before{color:#d54e21;content:"\f463";display:inline-block;font:20px/1 "dashicons";speak:none;padding:0;margin:0;vertical-align:top}.ai1wm-modal-dialog{position:fixed;top:0;left:0;bottom:0;right:0;background:rgba(0,0,0,.7);z-index:99999;opacity:0;transition:opacity 400ms ease-in;pointer-events:none}.ai1wm-modal-dialog:target{opacity:1;pointer-events:auto}.ai1wm-modal-dialog .ai1wm-modal-container{position:fixed;top:50%;right:50%;z-index:100002;width:480px;height:auto;padding:6px 16px 10px;-webkit-transform:translate(240px,-94px);transform:translate(240px,-94px);border:1px solid #fff;box-shadow:0 2px 6px #292929;border-radius:6px;background:#f6f6f6;box-sizing:border-box}.ai1wm-modal-dialog .ai1wm-modal-container .ai1wm-modal-error{color:red}.ai1wm-modal-dialog .ai1wm-modal-container .ai1wm-modal-buttons{text-align:right}.ai1wm-modal-dialog .ai1wm-modal-container .ai1wm-purchase-id{width:100%;padding:6px}.ai1wm-modal-dialog .ai1wm-modal-container .ai1wm-help-link{font-weight:700}.ai1wm-modal-dialog .ai1wm-modal-container .ai1wm-purchase-discard{margin-right:1em}.ai1wm-error-message,.ai1wm-update-message{padding:0;margin:0;color:red}/** * Send an action over AJAX. A wrapper around jQuery.ajax. In future, all consumers can be reviewed to simplify some of the options, where there is historical cruft. * N.B. updraft_iframe_modal() below uses the AJAX URL for the iframe's src attribute * * @param {string} action - the action to send * @param {*} data - data to send * @param {Function} callback - if specified, will be called with the results * @param {object} options -further options. Relevant properties include: * - [json_parse=true] - whether to JSON parse the results * - [alert_on_error=true] - whether to show an alert box if there was a problem (otherwise, suppress it) * - [action='updraft_ajax'] - what to send as the action parameter on the AJAX request (N.B. action parameter to this function goes as the 'subaction' parameter on the AJAX request) * - [nonce=updraft_credentialtest_nonce] - the nonce value to send. * - [nonce_key='nonce'] - the key value for the nonce field * - [timeout=null] - set a timeout after this number of seconds (or if null, none is set) * - [async=true] - control whether the request is asynchronous (almost always wanted) or blocking (would need to have a specific reason) * - [type='POST'] - GET or POST */ function updraft_send_command(action, data, callback, options) { default_options = { json_parse: true, alert_on_error: true, action: 'updraft_ajax', nonce: updraft_credentialtest_nonce, nonce_key: 'nonce', timeout: null, async: true, type: 'POST' } if ('undefined' === typeof options) options = {}; for (var opt in default_options) { if (!options.hasOwnProperty(opt)) { options[opt] = default_options[opt]; } } var ajax_data = { action: options.action, subaction: action, }; ajax_data[options.nonce_key] = options.nonce; // TODO: Once all calls are routed through here, change the listener in admin.php to always take the data from the 'data' attribute, instead of in the naked $_POST/$_GET if (typeof data == 'object') { for (var attrname in data) { ajax_data[attrname] = data[attrname]; } } else { ajax_data.action_data = data; } var ajax_opts = { type: options.type, url: ajaxurl, data: ajax_data, success: function(response, status) { if (options.json_parse) { try { var resp = ud_parse_json(response); } catch (e) { if ('function' == typeof options.error_callback) { return options.error_callback(response, e, 502, resp); } else { console.log(e); console.log(response); if (options.alert_on_error) { if ('string' === typeof response && response.match(/security\scheck\s?/i)) response += ' (' + updraftlion.expired_tokens + ' ' + updraftlion.reload_page + ')'; alert(updraftlion.unexpectedresponse+' '+response); } return; } } if (resp.hasOwnProperty('fatal_error')) { if ('function' == typeof options.error_callback) { // 500 is internal server error code return options.error_callback(response, status, 500, resp); } else { console.error(resp.fatal_error_message); if (options.alert_on_error) { alert(resp.fatal_error_message); } return false; } } if ('function' == typeof callback) callback(resp, status, response); } else { if ('function' == typeof callback) callback(response, status); } }, error: function(response, status, error_code) { if ('function' == typeof options.error_callback) { options.error_callback(response, status, error_code); } else { console.log("updraft_send_command: error: "+status+" ("+error_code+")"); console.log(response); } }, dataType: 'text', async: options.async }; if (null != options.timeout) { ajax_opts.timeout = options.timeout; } jQuery.ajax(ajax_opts); } /** * Opens the dialog box for confirmation of whether to delete a backup, plus options if relevant * * @param {string} key - The UNIX timestamp of the backup * @param {string} nonce - The backup job ID * @param {boolean} showremote - Whether or not to show the "also delete from remote storage?" checkbox */ function updraft_delete(key, nonce, showremote) { jQuery('#updraft_delete_timestamp').val(key); jQuery('#updraft_delete_nonce').val(nonce); if (showremote) { jQuery('#updraft-delete-remote-section, #updraft_delete_remote').prop('disabled', false).show(); } else { jQuery('#updraft-delete-remote-section, #updraft_delete_remote').hide().attr('disabled','disabled'); } if (key.indexOf(',') > -1) { jQuery('#updraft_delete_question_singular').hide(); jQuery('#updraft_delete_question_plural').show(); } else { jQuery('#updraft_delete_question_plural').hide(); jQuery('#updraft_delete_question_singular').show(); } jQuery('#updraft-delete-modal').dialog('open'); } function updraft_remote_storage_tab_activation(the_method){ jQuery('.updraftplusmethod').not('.error').hide(); jQuery('.remote-tab').data('active', false); jQuery('.remote-tab').removeClass('nav-tab-active'); jQuery('.updraftplusmethod.'+the_method).show(); jQuery('.remote-tab-'+the_method).data('active', true); jQuery('.remote-tab-'+the_method).addClass('nav-tab-active'); } /** * Set the email report's setting to a different interface when email storage is selected * * @param {boolean} value True to set the email report setting to another interface, false otherwise */ function set_email_report_storage_interface(value) { jQuery('#cb_not_email_storage_label').css('display', true === value ? 'none' : 'inline'); jQuery('#cb_email_storage_label').css('display', true === value ? 'inline' : 'none'); if (true === value) { jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').on('click', function(e) { return false; }); } else { jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').prop("onclick", null).off("click"); } if (!jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').is(':checked')) { jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').prop('checked', value); } jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').prop('disabled', value); var updraft_email = jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon input#updraft_email').val(); jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon label.email_report input[type="hidden"]').remove(); if (true === value) { jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon label.email_report input#updraft_email').after(''); } } /** * Check how many cron jobs are overdue, and display a message if it is several (as determined by the back-end) */ function updraft_check_overduecrons() { updraft_send_command('check_overdue_crons', null, function(response) { if (response && response.hasOwnProperty('m') && Array.isArray(response.m)) { for (var i in response.m) { jQuery('#updraft-insert-admin-warning').append(response.m[i]); } } }, { alert_on_error: false }); } function updraft_remote_storage_tabs_setup() { var anychecked = 0; var set = jQuery('.updraft_servicecheckbox:checked'); jQuery(set).each(function(ind, obj) { var ser = jQuery(obj).val(); jQuery('.error.updraftplusmethod.'+ser).show(); if (jQuery(obj).attr('id') != 'updraft_servicecheckbox_none') { anychecked++; } jQuery('.remote-tab-'+ser).show(); if (ind == jQuery(set).length-1) { updraft_remote_storage_tab_activation(ser); } }); if (anychecked > 0) { jQuery('.updraftplusmethod.none').hide(); jQuery('#remote_storage_tabs').show(); } else { jQuery('#remote_storage_tabs').hide(); } // To allow labelauty remote storage buttons to be used with keyboard jQuery(document).on('keyup', function(event) { if (32 === event.keyCode || 13 === event.keyCode) { if (jQuery(document.activeElement).is("input.labelauty + label")) { var for_box = jQuery(document.activeElement).attr("for"); if (for_box) { jQuery("#"+for_box).trigger('change'); } } } }); jQuery('.updraft_servicecheckbox').on('change', function() { var sclass = jQuery(this).attr('id'); if ('updraft_servicecheckbox_' == sclass.substring(0,24)) { var serv = sclass.substring(24); if (null != serv && '' != serv) { if (jQuery(this).is(':checked')) { anychecked++; jQuery('.error.updraftplusmethod.'+serv).show(); jQuery('.remote-tab-'+serv).fadeIn(); updraft_remote_storage_tab_activation(serv); if (jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon').length && 'email' === serv) set_email_report_storage_interface(true); } else { anychecked--; jQuery('.error.updraftplusmethod.'+serv).hide(); jQuery('.remote-tab-'+serv).hide(); // Check if this was the active tab, if yes, switch to another if (jQuery('.remote-tab-'+serv).data('active') == true) { updraft_remote_storage_tab_activation(jQuery('.remote-tab:visible').last().attr('name')); } if (jQuery('#updraft-navtab-settings-content #updraft_report_row_no_addon').length && 'email' === serv) set_email_report_storage_interface(false); } } } if (anychecked <= 0) { jQuery('.updraftplusmethod.none').fadeIn(); jQuery('#remote_storage_tabs').hide(); } else { jQuery('.updraftplusmethod.none').hide(); jQuery('#remote_storage_tabs').show(); } }); // Add stuff for free version jQuery('.updraft_servicecheckbox:not(.multi)').on('change', function() { set_email_report_storage_interface(false); var svalue = jQuery(this).attr('value'); if (jQuery(this).is(':not(:checked)')) { jQuery('.updraftplusmethod.'+svalue).hide(); jQuery('.updraftplusmethod.none').fadeIn(); } else { jQuery('.updraft_servicecheckbox').not(this).prop('checked', false); if ('email' === svalue) { set_email_report_storage_interface(true); } } }); var servicecheckbox = jQuery('.updraft_servicecheckbox'); if (typeof servicecheckbox.labelauty === 'function') { servicecheckbox.labelauty(); var $vault_label = jQuery('label[for=updraft_servicecheckbox_updraftvault]'); var $vault_info = jQuery('
'+updraftlion.rescanningremote+'
'); } else { updraft_history_lastchecksum = false; jQuery('#updraft-navtab-backups-content .updraft_existing_backups').html(''+updraftlion.rescanning+'
'); } } var what_op = remotescan ? 'remotescan' : (rescan ? 'rescan' : false); var data = { operation: what_op, debug: debug, backup_count: backup_count, } updraft_send_command('rescan', data, function(resp) { if (resp.hasOwnProperty('logs_exist') && resp.logs_exist) { // Show the "most recently modified log" link, in case it was previously hidden (if there were no logs until now) jQuery('#updraft_lastlogmessagerow .updraft-log-link').show(); } if (resp.hasOwnProperty('migrate_tab') && resp.migrate_tab) { if (!jQuery('#updraft-navtab-migrate').hasClass('nav-tab-active')) { jQuery('#updraft_migrate_tab_alt').html(''); jQuery('#updraft_migrate').replaceWith(jQuery(resp.migrate_tab).find('#updraft_migrate')); setup_migrate_tabs(); } } if (resp.hasOwnProperty('web_server_disk_space')) { if ('' == resp.web_server_disk_space) { console.log("UpdraftPlus: web_server_disk_space is empty"); if (jQuery('#updraft-navtab-backups-content .updraft-server-disk-space').length) { jQuery('#updraft-navtab-backups-content .updraft-server-disk-space').slideUp('slow', function() { jQuery(this).remove(); }); } } else { if (jQuery('#updraft-navtab-backups-content .updraft-server-disk-space').length) { jQuery('#updraft-navtab-backups-content .updraft-server-disk-space').replaceWith(resp.web_server_disk_space); } else { jQuery('#updraft-navtab-backups-content .updraft-disk-space-actions').prepend(resp.web_server_disk_space); } } } update_backupnow_modal(resp); if (resp.hasOwnProperty('backupnow_file_entities')) { impossible_increment_entities = resp.backupnow_file_entities; } if (resp.n != null) { jQuery('#updraft-existing-backups-heading').html(resp.n); } if (resp.t != null) { if (resp.cksum != null) { if (resp.cksum == updraft_history_lastchecksum) { // Avoid unnecessarily refreshing the HTML if the data is the same. This helps avoid resetting the DOM (annoying when debugging), and keeps user row selections. return; } updraft_history_lastchecksum = resp.cksum; } jQuery('#updraft-navtab-backups-content .updraft_existing_backups').html(resp.t); updraft_backups_selection.checkSelectionStatus(); if (resp.data) { console.log(resp.data); } } }); } /** * This function will check if the passed in response contains content for the backup now modal that needs updating on page * * @param {array} response - an array that may contain backupnow_modal content that needs updating */ function update_backupnow_modal(response) { if (response.hasOwnProperty('modal_afterfileoptions')) { jQuery('.backupnow_modal_afterfileoptions').html(response.modal_afterfileoptions); } } /** * Exclude entities hidden input field update * * @param {string} include_entity_name - backup entity name */ function updraft_exclude_entity_update(include_entity_name) { var exclude_entities = []; jQuery('#updraft_include_'+include_entity_name+'_exclude_container .updraft_exclude_entity_wrapper .updraft_exclude_entity_field').each(function() { var data_val = jQuery(this).data('val').toString().trim(); if ('' != data_val) { exclude_entities.push(data_val); } }); jQuery('#updraft_include_'+include_entity_name+'_exclude').val(exclude_entities.join(',')); } /** * Check uniqueness of exclude rule in include_backup_file * * @param {string} exclude_rule - exclude rule * @param {string} include_backup_file - the backup file type on which the exclude_rule will be applied * * @return {boolean} true if exclude_rule is unique otherwise false */ function updraft_is_unique_exclude_rule(exclude_rule, include_backup_file) { existing_exclude_rules_str = jQuery('#updraft_include_'+include_backup_file+'_exclude').val(); existing_exclude_rules = existing_exclude_rules_str.split(','); if (jQuery.inArray(exclude_rule, existing_exclude_rules) > -1) { alert(updraftlion.duplicate_exclude_rule_error_msg) return false; } else { return true; } } var updraft_interval_week_val = false; var updraft_interval_month_val = false; function updraft_intervals_monthly_or_not(selector_id, now_showing) { var selector = '#updraft-navtab-settings-content #'+selector_id; var current_length = jQuery(selector+' option').length; var is_monthly = ('monthly' == now_showing) ? true : false; var existing_is_monthly = false; if (current_length > 10) { existing_is_monthly = true; } if (!is_monthly && !existing_is_monthly) { return; } if (is_monthly && existing_is_monthly) { if ('monthly' == now_showing) { // existing_is_monthly does not mean the same as now_showing=='monthly'. existing_is_monthly refers to the drop-down, not whether the drop-down is being displayed. We may need to add these words back. jQuery('.updraft_monthly_extra_words_'+selector_id).remove(); jQuery(selector).before(''+updraftlion.day+' ').after(' '+updraftlion.inthemonth+' '); } return; } jQuery('.updraft_monthly_extra_words_'+selector_id).remove(); if (is_monthly) { // Save the old value updraft_interval_week_val = jQuery(selector+' option:selected').val(); jQuery(selector).html(updraftlion.mdayselector).before(''+updraftlion.day+' ').after(' '+updraftlion.inthemonth+' '); var select_mday = (updraft_interval_month_val === false) ? 1 : updraft_interval_month_val; // Convert from day of the month (ordinal) to option index (starts at 0) select_mday = select_mday - 1; jQuery(selector+" option").eq(select_mday).prop('selected', true); } else { // Save the old value updraft_interval_month_val = jQuery(selector+' option:selected').val(); jQuery(selector).html(updraftlion.dayselector); var select_day = (updraft_interval_week_val === false) ? 1 : updraft_interval_week_val; jQuery(selector+" option").eq(select_day).prop('selected', true); } } function updraft_check_same_times() { var dbmanual = 0; var file_interval = jQuery('#updraft-navtab-settings-content .updraft_interval').val(); if (file_interval == 'manual') { // jQuery('#updraft_files_timings').css('opacity', '0.25'); jQuery('#updraft-navtab-settings-content .updraft_files_timings').hide(); } else { // jQuery('#updraft_files_timings').css('opacity', 1); jQuery('#updraft-navtab-settings-content .updraft_files_timings').show(); } if ('weekly' == file_interval || 'fortnightly' == file_interval || 'monthly' == file_interval) { updraft_intervals_monthly_or_not('updraft_startday_files', file_interval); jQuery('#updraft-navtab-settings-content #updraft_startday_files').show(); } else { jQuery('.updraft_monthly_extra_words_updraft_startday_files').remove(); jQuery('#updraft-navtab-settings-content #updraft_startday_files').hide(); } var db_interval = jQuery('#updraft-navtab-settings-content .updraft_interval_database').val(); if (db_interval == 'manual') { dbmanual = 1; // jQuery('#updraft_db_timings').css('opacity', '0.25'); jQuery('#updraft-navtab-settings-content .updraft_db_timings').hide(); } if ('weekly' == db_interval || 'fortnightly' == db_interval || 'monthly' == db_interval) { updraft_intervals_monthly_or_not('updraft_startday_db', db_interval); jQuery('#updraft-navtab-settings-content #updraft_startday_db').show(); } else { jQuery('.updraft_monthly_extra_words_updraft_startday_db').remove(); jQuery('#updraft-navtab-settings-content #updraft_startday_db').hide(); } if (db_interval == file_interval) { // jQuery('#updraft_db_timings').css('opacity','0.25'); jQuery('#updraft-navtab-settings-content .updraft_db_timings').hide(); // jQuery('#updraft_same_schedules_message').show(); if (0 == dbmanual) { jQuery('#updraft-navtab-settings-content .updraft_same_schedules_message').show(); } else { jQuery('#updraft-navtab-settings-content .updraft_same_schedules_message').hide(); } } else { jQuery('#updraft-navtab-settings-content .updraft_same_schedules_message').hide(); if (0 == dbmanual) { // jQuery('#updraft_db_timings').css('opacity', '1'); jQuery('#updraft-navtab-settings-content .updraft_db_timings').show(); } } } // Visit the site in the background every 3.5 minutes - ensures that backups can progress if you've got the UD settings page open if ('undefined' !== typeof updraft_siteurl) { setInterval(function() { jQuery.get(updraft_siteurl+'/wp-cron.php');}, 210000); } function updraft_activejobs_delete(jobid) { updraft_aborted_jobs[jobid] = 1; jQuery('#updraft-jobid-'+jobid).closest('.updraft_row').addClass('deleting'); updraft_send_command('activejobs_delete', jobid, function(resp) { var job_row = jQuery('#updraft-jobid-'+jobid).closest('.updraft_row'); job_row.addClass('deleting'); if (resp.ok == 'Y') { jQuery('#updraft-jobid-'+jobid).html(resp.m); job_row.remove(); // inpage backup - Close modal if canceling backup if (jQuery('#updraft-backupnow-inpage-modal').dialog('isOpen')) jQuery('#updraft-backupnow-inpage-modal').dialog('close'); updraft_show_success_modal({ message: updraft_active_job_is_clone(jobid) ? updraftlion.clone_backup_aborted : updraftlion.backup_aborted, icon: 'no-alt', classes: 'warning' }); } else if ('N' == resp.ok) { job_row.removeClass('deleting'); alert(resp.m); } else { job_row.removeClass('deleting'); alert(updraftlion.unexpectedresponse); console.log(resp); } }); } function updraftplus_diskspace_entity(key) { jQuery('#updraft_diskspaceused_'+key).html(''+updraftlion.calculating+''); updraft_send_command('get_fragment', { fragment: 'disk_usage', data: key }, function(response) { jQuery('#updraft_diskspaceused_'+key).html(response.output); }, { type: 'GET' }); } /** * Checks if the specified job is a clone * * @param {string} job_id The job ID * * @return {int} */ function updraft_active_job_is_clone(job_id) { return updraft_clone_jobs.filter(function(val) { return val == job_id; }).length; } /** * Open a modal with content fetched from an iframe * * @param {String} getwhat - the subaction parameter to pass to UD's AJAX handler * @param {String} title - the title for the modal */ function updraft_iframe_modal(getwhat, title) { var width = 780; var height = 500; jQuery('#updraft-iframe-modal-innards').html(''); jQuery('#updraft-iframe-modal').dialog({ title: title, resizeOnWindowResize: true, scrollWithViewport: true, resizeAccordingToViewport: true, useContentSize: false, open: function(event, ui) { jQuery(this).dialog('option', 'width', width), jQuery(this).dialog('option', 'minHeight', 260); if (jQuery(window).height() > height) { jQuery(this).dialog('option', 'height', height); } else { jQuery(this).dialog('option', 'height', jQuery(window).height()-30); } } }).dialog('open'); } function updraft_html_modal(showwhat, title, width, height) { jQuery('#updraft-iframe-modal-innards').html(showwhat); var updraft_html_modal_buttons = {}; if (width < 450) { updraft_html_modal_buttons[updraftlion.close] = function() { jQuery(this).dialog("close"); }; } jQuery('#updraft-iframe-modal').dialog({ title: title, buttons: updraft_html_modal_buttons, resizeOnWindowResize: true, scrollWithViewport: true, resizeAccordingToViewport: true, useContentSize: false, open: function(event, ui) { jQuery(this).dialog('option', 'width', width), jQuery(this).dialog('option', 'minHeight', 260); if (jQuery(window).height() > height) { jQuery(this).dialog('option', 'height', height); } else { jQuery(this).dialog('option', 'height', jQuery(window).height()-30); } } }).dialog('open'); } function updraftplus_diskspace() { jQuery('#updraft-navtab-backups-content .updraft_diskspaceused').html(''+updraftlion.calculating+''); updraft_send_command('get_fragment', { fragment: 'disk_usage', data: 'updraft' }, function(response) { jQuery('#updraft-navtab-backups-content .updraft_diskspaceused').html(response.output); }, { type: 'GET' }); } var lastlog_lastmessage = ""; function updraftplus_deletefromserver(timestamp, type, findex) { if (!findex) findex=0; var pdata = { stage: 'delete', timestamp: timestamp, type: type, findex: findex }; updraft_send_command('updraft_download_backup', pdata, null, { action: 'updraft_download_backup', nonce: updraft_download_nonce, nonce_key: '_wpnonce' }); } function updraftplus_downloadstage2(timestamp, type, findex) { location.href =ajaxurl+'?_wpnonce='+updraft_download_nonce+'×tamp='+timestamp+'&type='+type+'&stage=2&findex='+findex+'&action=updraft_download_backup'; } function updraftplus_show_contents(timestamp, type, findex) { var modal_content = '' + updraftlion.zip_file_contents_info + ' -
'+updraftlion.browse_download_link+''+resp.fatal_error_message+'
'); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; jQuery('#updraft_zip_files_jstree').html(''+error_message+'
'); console.log(error_message); alert(error_message); console.log(response); } } }); }, "error": function(error) { alert(error); console.log(error); }, }, "search": { "show_only_matches": true }, "plugins": ["search", "sort"], }); // Update modal title once tree loads jQuery('#updraft_zip_files_jstree').on('ready.jstree', function(e, data) { jQuery('#updraft-iframe-modal').dialog('option', 'title', updraftlion.zip_file_contents + ': ' + data.instance.get_node('#').children[0]) }); // Search function for jstree, this will hide nodes that don't match the search var timeout = false; jQuery('#zip_files_jstree_search').on('keyup', function () { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(function () { var value = jQuery('#zip_files_jstree_search').val(); jQuery('#updraft_zip_files_jstree').jstree(true).search(value); }, 250); }); // Detect change on the tree and update the input that has been marked as editing jQuery('#updraft_zip_files_jstree').on("changed.jstree", function (e, data) { jQuery('#updraft_zip_path_text').text(data.node.li_attr.path); if (data.node.li_attr.size) { jQuery('#updraft_zip_size_text').text(data.node.li_attr.size); jQuery('#updraft_zip_download_item').show(); } else { jQuery('#updraft_zip_size_text').text(''); jQuery('#updraft_zip_download_item').hide(); } }); jQuery('#updraft_zip_download_item').on('click', function(event) { event.preventDefault(); var path = jQuery('#updraft_zip_path_text').text(); updraft_send_command('get_zipfile_download', {path:path, timestamp:timestamp, type:type, findex:findex}, function(response) { if (response.hasOwnProperty('error')) { alert(response.error); } else if (response.hasOwnProperty('path')) { location.href =ajaxurl+'?_wpnonce='+updraft_download_nonce+'×tamp='+timestamp+'&type='+type+'&stage=2&findex='+findex+'&filepath='+response.path+'&action=updraft_download_backup'; } else { alert(updraftlion.download_timeout); } }, { error_callback: function(response, status, error_code, resp) { if (typeof resp !== 'undefined' && resp.hasOwnProperty('fatal_error')) { console.error(resp.fatal_error_message); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; console.log(error_message); alert(error_message); console.log(response); } } }); }); } /** * This function will clean up the updraft downloader UI * * @param {object} item - the object pressed in the UI * @param {string} what - the file entity */ function remove_updraft_downloader(item, what) { jQuery(item).closest('.updraftplus_downloader').fadeOut().remove(); if (0 == jQuery('.updraftplus_downloader_container_'+what+' .updraftplus_downloader').length) jQuery('.updraftplus_downloader_container_'+what).remove(); } /** * This function will prepare the downloader UI and kick of the request to download the file entities. * * @param {string} base - the base string for the id * @param {integer} backup_timestamp - the backup timestamp * @param {string} what - the file entity * @param {string} whicharea - the area we want to append the downloader * @param {string} set_contents - the contents we want to download * @param {string} prettydate - the pretty backup date * @param {boolean} async - boolean to indicate if this is a async request or not */ function updraft_downloader(base, backup_timestamp, what, whicharea, set_contents, prettydate, async) { if (typeof set_contents !== "string") set_contents = set_contents.toString(); jQuery('.ud_downloadstatus').show(); var set_contents = set_contents.split(','); var prdate = (prettydate) ? prettydate : backup_timestamp; // Old-style, from when it was a form // var data = jQuery('#updraft-navtab-backups-content .uddownloadform_'+what+'_'+backup_timestamp+'_'+set_contents[i]).serialize(); var nonce = jQuery('#updraft-navtab-backups-content .uddownloadform_'+what+'_'+backup_timestamp+'_'+set_contents[0]).data('wp_nonce').toString(); if (!jQuery('.updraftplus_downloader_container_'+what).length) { jQuery(whicharea).append(''); jQuery('.updraftplus_downloader_container_' + what).append('' + updraftlion.download + ' ' + what + ' (' + prdate + '):'); } for (var i = 0; i < set_contents.length; i++) { // Create somewhere for the status to be found var stid = base+backup_timestamp+'_'+what+'_'+set_contents[i]; var stid_selector = '.'+stid; var show_index = parseInt(set_contents[i]); show_index++; var itext = (0 == set_contents[i]) ? '' : ' ('+show_index+')'; if (!jQuery(stid_selector).length) { jQuery('.updraftplus_downloader_container_'+what).append('' + updraftlion.warnings +'
' + resp.w + '' + updraftlion.errors+'
' + resp.e + ''+resp.fatal_error_message+'
'); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; jQuery('#updraft-restore-modal-stage2a').html(''+error_message+'
'); console.log(error_message); alert(error_message); console.log(response); } } }); } function updraft_downloader_status(base, nonce, what, findex) { // Short-circuit. See previous versions for the old code. return; } function updraft_downloader_status_update(download_status, response_raw) { var cancel_repeat = 0; jQuery(download_status).each(function (x, dstatus) { if (dstatus.base == '') return; var stid = dstatus.base + dstatus.timestamp + '_' + dstatus.what + '_' + dstatus.findex; var stid_selector = '.' + stid; if (dstatus.e != null) { jQuery(stid_selector + ' .raw').html('' + updraftlion.error + ' ' + dstatus.e); console.log(dstatus); } else if (dstatus.p != null) { jQuery(stid_selector + '_st .dlfileprogress').width(dstatus.p + '%'); // jQuery(stid_selector+'_st .dlsofar').html(Math.round(dstatus.s/1024)); // jQuery(stid_selector+'_st .dlsize').html(Math.round(dstatus.t/1024)); // Is a restart appropriate? // dstatus.a, if set, indicates that a) the download is incomplete and b) the value is the number of seconds since the file was last modified... if (dstatus.a != null && dstatus.a > 0) { var timenow = (new Date).getTime(); var lasttimebegan = jQuery(stid_selector).data('lasttimebegan'); // Remember that this is in milliseconds var sincelastrestart = timenow - lasttimebegan; if (dstatus.a > 90 && sincelastrestart > 60000) { console.log(dstatus.timestamp + " " + dstatus.what + " " + dstatus.findex + ": restarting download: file_age=" + dstatus.a + ", sincelastrestart_ms=" + sincelastrestart); jQuery(stid_selector).data('lasttimebegan', (new Date).getTime()); var $original_button = jQuery('#updraft-navtab-backups-content .uddownloadform_' + dstatus.what + '_' + dstatus.timestamp + '_' + dstatus.findex); var data = { type: dstatus.what, timestamp: dstatus.timestamp, findex: dstatus.findex }; var options = { action: 'updraft_download_backup', nonce_key: '_wpnonce', nonce: $original_button.data('wp_nonce').toString(), timeout: 10000 }; updraft_send_command('updraft_download_backup', data, null, options); jQuery(stid_selector).data('lasttimebegan', (new Date).getTime()); } } if (dstatus.m != null) { if (dstatus.p >= 100 && 'udrestoredlstatus_' == dstatus.base) { jQuery(stid_selector + ' .raw').html(dstatus.m); jQuery(stid_selector).fadeOut('slow', function () { remove_updraft_downloader(this, dstatus.what); updraft_restorer_checkstage2(0); }); } else if (dstatus.p >= 100 && dstatus.base == 'udclonedlstatus_') { jQuery(stid_selector + ' .raw').html(dstatus.m); jQuery(stid_selector).fadeOut('slow', function () { remove_updraft_downloader(this, dstatus.what); }); } else if (dstatus.p < 100 || dstatus.base != 'uddlstatus_') { jQuery(stid_selector + ' .raw').html(dstatus.m); } else { var file_ready_actions = updraftlion.fileready + ' ' + '(size: ' + convert_numeric_size_to_text(dstatus.s) + '). ' + updraftlion.actions + ':\ \ '; if (dstatus.hasOwnProperty('can_show_contents') && dstatus.can_show_contents) { file_ready_actions += ' '; } jQuery(stid_selector + ' .raw').html(file_ready_actions); jQuery(stid_selector + '_st').remove(); } } // dlstatus_lastlog = response_raw; } else if (dstatus.m != null) { jQuery(stid_selector + ' .raw').html(dstatus.m); } else { jQuery(stid_selector + ' .raw').html(updraftlion.jsonnotunderstood + ' (' + response_raw + ')'); cancel_repeat = 1; } }); return cancel_repeat; } /** * Converts a number of bytes into a suitable textual unit value * * @param {long} bytes * @returns string */ function convert_numeric_size_to_text(bytes) { if (1024 > bytes) { return bytes + " b"; } else if (1024 * 1024 >bytes) { return (bytes / 1024).toFixed(2) + " KB"; } else if (1024 * 1024 * 1024 > bytes ) { return (bytes / (1024 * 1024)).toFixed(2) + " MB"; } else { return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB"; } } /** * Function that sets up a ajax call to start a backup * * @param {Integer} backupnow_nodb Indicate whether the database should be backed up: valid values are 0, 1 * @param {Integer} backupnow_nofiles Indicate whether any files should be backed up: valid values are 0, 1 * @param {Integer} backupnow_nocloud Indicate whether the backup should be uploaded to cloud storage: valid values are 0, 1 * @param {String} onlythesefileentities A csv list of file entities to be backed up * @param {String} onlythesetableentities A csv list of table entities to be backed up * @param {Array} extradata any extra data to be added * @param {String} label A optional label to be added to a backup * @param {String} only_these_cloud_services An array of remote sorage locations to be backed up to */ function updraft_backupnow_go(backupnow_nodb, backupnow_nofiles, backupnow_nocloud, onlythesefileentities, extradata, label, onlythesetableentities, only_these_cloud_services) { var params = { backupnow_nodb: backupnow_nodb, backupnow_nofiles: backupnow_nofiles, backupnow_nocloud: backupnow_nocloud, backupnow_label: label, extradata: extradata }; if ('' != onlythesefileentities) { params.onlythisfileentity = onlythesefileentities; } if ('' != onlythesetableentities) { params.onlythesetableentities = onlythesetableentities; } if ('' != only_these_cloud_services) { params.only_these_cloud_services = only_these_cloud_services; } params.always_keep = (typeof extradata.always_keep !== 'undefined') ? extradata.always_keep : 0; delete extradata.always_keep; params.incremental = (typeof extradata.incremental !== 'undefined') ? extradata.incremental : 0; delete extradata.incremental; params.db_anon_all = (typeof extradata.db_anon !== 'undefined' && typeof extradata.db_anon.all !== 'undefined') ? extradata.db_anon.all : 0; params.db_anon_non_staff = (typeof extradata.db_anon !== 'undefined' && typeof extradata.db_anon.non_staff !== 'undefined') ? extradata.db_anon.non_staff : 0; params.db_anon_wc_orders = (typeof extradata.db_anon !== 'undefined' && typeof extradata.db_anon.wc_orders !== 'undefined') ? extradata.db_anon.wc_orders : 0; if ('undefined' !== typeof extradata.db_anon) { delete extradata.db_anon.all; delete extradata.db_anon.non_staff; delete extradata.db_anon.wc_orders; } // Display Request start message if (!jQuery('.updraft_requeststart').length) { var requeststart_el = jQuery('').html(''+updraftlion.requeststart); requeststart_el.data('remove', false); setTimeout( function() { requeststart_el.data('remove', true); }, 3000 ); setTimeout( function() { requeststart_el.remove(); }, 75000 ); jQuery('#updraft_activejobsrow').before(requeststart_el); } updraft_activejobslist_backupnownonce_only = 1; updraft_send_command('backupnow', params, function(resp) { if (resp.hasOwnProperty('error')) { jQuery('.updraft_requeststart').remove(); alert(resp.error); return; } jQuery('#updraft_backup_started').html(resp.m); if (resp.hasOwnProperty('nonce')) { // Can't return it from this context updraft_backupnow_nonce = resp.nonce; console.log("UpdraftPlus: ID of started job: "+updraft_backupnow_nonce); } setTimeout(function() { updraft_activejobs_update(true);}, 500); }); } jQuery(function($) { // actioned When the checkout embed is complete $(document).on('udp/checkout/done', function(e, data) { if (data.hasOwnProperty('product') && 'updraftpremium' === data.product && 'complete' === data.status) { $('.premium-upgrade-purchase-success').show(); $('.updraft_feat_table').closest('section').hide(); $('.updraft_premium_cta__action').hide(); } }); // Advanced settings new menu button listeners $('.expertmode .advanced_settings_container .advanced_tools_button').on('click', function() { advanced_tool_hide($(this).attr("id")); }); function advanced_tool_hide(show_tool) { $('.expertmode .advanced_settings_container .advanced_tools:not(".'+show_tool+'")').hide(); $('.expertmode .advanced_settings_container .advanced_tools.'+show_tool).fadeIn('slow'); $('.expertmode .advanced_settings_container .advanced_tools_button:not(#'+show_tool+')').removeClass('active'); $('.expertmode .advanced_settings_container .advanced_tools_button#'+show_tool).addClass('active'); } // https://github.com/select2/select2/issues/1246#issuecomment-71710835 if (jQuery.ui && jQuery.ui.dialog && jQuery.ui.dialog.prototype._allowInteraction) { var ui_dialog_interaction = jQuery.ui.dialog.prototype._allowInteraction; jQuery.ui.dialog.prototype._allowInteraction = function(e) { if (jQuery(e.target).closest('.select2-dropdown').length) return true; return ui_dialog_interaction.apply(this, arguments); }; } // Update WebDAV URL as user edits $('#updraft-navtab-settings-content #remote-storage-holder').on('change keyup paste', '.updraft_webdav_settings', function() { var attr_id = $(this).attr('id'); if ('string' !== typeof attr_id) return; var parsed_attr_id = attr_id.match(/updraft_webdav_(.+)_(s-[^_]+)$/i); if (!parsed_attr_id || !parsed_attr_id[1] || !parsed_attr_id[2]) return; var instance_id = parsed_attr_id[2], webdav_input = parsed_attr_id[1].toLowerCase(), masked_password = ''; if ('host' === webdav_input) { $('.webdav-'+instance_id+' .updraft_webdav_host_error').hide(); if ($(this).val().indexOf("@") >= 0) { $(this).val($(this).val().replaceAll('@', encodeURIComponent('@'))); } else if ($(this).val().indexOf("/") >= 0) { $(this).val($(this).val().replaceAll('/', '')); $('.webdav-'+instance_id+' .updraft_webdav_host_error').show(); } } else if ('path' === webdav_input && 0 == $(this).val().indexOf('/')) { $(this).val($(this).val().replace(/^[\/]+/, '')); } var webdav = $('#updraft_webdav_webdav_' + instance_id).val(), host = $('#updraft_webdav_host_' + instance_id).val() || '', user = $('#updraft_webdav_user_' + instance_id).val() || '', password = $('#updraft_webdav_pass_' + instance_id).val() || '', port = $('#updraft_webdav_port_' + instance_id).val() || '', path = $('#updraft_webdav_path_' + instance_id).val() || ''; if (password) { masked_password = password.replace(/./gi,'*'); } if (user && password) { user += ':'; } if ((user || password) && host) { masked_password += '@'; password += '@'; } if (host && port) { host += ':'; } if (path) { path = '/' + path; } $('#updraft_webdav_url_' + instance_id).val(webdav + user + password + host + port + path); $('#updraft_webdav_masked_url_' + instance_id).val(webdav + user + masked_password + host + port + path); }); $('div.ud-phpseclib-notice').on('click', 'button.notice-dismiss', function (event) { event.stopImmediatePropagation(); updraft_send_command('dismiss_phpseclib_notice', null, function(resp, status, response) { if (!resp.hasOwnProperty('success') || 1 !== resp.success) { console.log(resp); alert(updraftlion.unexpectedresponse+' '+response); } }); }); // Delete button $('#updraft-navtab-backups-content').on('click', '.js--delete-selected-backups', function(e) { e.preventDefault(); updraft_deleteallselected(); }); $('#updraft-navtab-backups-content').on('click', '.updraft_existing_backups .backup-select input', function(e) { // e.preventDefault(); updraft_backups_selection.toggle($(this).closest('.updraft_existing_backups_row')); }); $('#updraft-navtab-backups-content').on('click', '#cb-select-all', function(e) { if ($(this).is(':checked')) { updraft_backups_selection.selectAll(); } else { updraft_backups_selection.deselectAll(); } }); $('#updraft-wrap').on('click', '[id^=updraftplus_manual_authorisation_submit_]', function(e) { e.preventDefault(); var method = $(this).data('method'); var auth_data = $('#updraftplus_manual_authentication_data_'+method).val(); $('#updraftplus_manual_authentication_error_'+method).text(); $('#updraft-wrap #updraftplus_manual_authorisation_template_'+method+' .updraftplus_spinner.spinner').addClass('visible'); $('#updraftplus_manual_authorisation_submit_'+method).prop('disabled', true); manual_remote_storage_auth(method, auth_data); }); /** * This method will send the ajax request to manually authenticate the remote storage method and then update the page with the response * * @param {string} method - the remote storage method * @param {string} auth_data - the auth data as a base64 json encoded string */ function manual_remote_storage_auth(method, auth_data) { updraft_send_command('manual_remote_storage_authentication', {method: method, auth_data: auth_data}, function(response) { $('#updraft-wrap #updraftplus_manual_authorisation_template_'+method+' .updraftplus_spinner.spinner').removeClass('visible'); if (response.hasOwnProperty('result') && 'success' === response.result) { $('#updraft-wrap .updraftplus-top-menu').before(response.data); $('#updraft-wrap #updraftplus_manual_authorisation_template_'+method).parent().remove(); $('#updraft-wrap .updraft_authenticate_'+method).remove(); } else if (response.hasOwnProperty('result') && 'error' === response.result) { $('#updraftplus_manual_authentication_error_'+method).text(response.data); $('#updraftplus_manual_authorisation_submit_'+method).prop('disabled', false); } }); } $('#updraft-navtab-backups-content').on('click', '.js--select-all-backups', function(e) { updraft_backups_selection.selectAll(); }); $('#updraft-navtab-backups-content').on('click', '.js--deselect-all-backups', function(e) { updraft_backups_selection.deselectAll(); }); $('#updraft-navtab-backups-content').on('click', '.updraft_existing_backups .updraft_existing_backups_row', function(e) { if (!e.ctrlKey && !e.metaKey) return; if (e.shiftKey) { // it's multiple range selection, it requires the user to hold shift+ctrl buttons during the range selection, the initial and the new starting index is saved in firstMultipleSelectionIndex variable if ("undefined" == typeof updraft_backups_selection.firstMultipleSelectionIndex) { // if all the above conditions are fulfilled then we need to set up the keyup event handler only for range selection operation. By doing it, we also ignore the Apple Command (metaKey) keycode checking which varies among the browser https://unixpapa.com/js/key.html $(document).on('keyup.MultipleSelection', function(e) { // multiple range selection operation requires the user to hold ctrl/cmd + shift buttons all the time during the selections, the range selection operation will be canceled if the user releases one of the held buttons (shitf or ctrl/cmd) and if that happens the highlight mode will stop working updraft_backups_selection.unregister_highlight_mode(); // once this event handler has been triggered and the highlight mode has been turned off, this event handler needs to be removed by using its namespace .MultipleSelection $(document).off('.MultipleSelection'); }); updraft_backups_selection.select(this); $(this).addClass('range-selection-start'); updraft_backups_selection.register_highlight_mode(); } else { updraft_backups_selection.selectAllInBetween(this); jQuery('#updraft-navtab-backups-content .updraft_existing_backups .updraft_existing_backups_row').removeClass('range-selection'); } // set the new starting index to the ending range index updraft_backups_selection.firstMultipleSelectionIndex = this.rowIndex - 1; } else { updraft_backups_selection.toggle(this); } }); updraft_backups_selection.checkSelectionStatus(); $('#updraft-navtab-addons-content .wrap').on('click', '.updraftplus_com_login .ud_connectsubmit', function (e) { e.preventDefault(); var email = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_email').val(); var password = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_password').val(); var auto_update = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_auto_updates').is(':checked') ? 1: 0; var auto_udc_connect = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_auto_udc_connect').is(':checked') ? 1: 0; var options = { email: email, password: password, auto_update: auto_update, auto_udc_connect: auto_udc_connect }; updraftplus_com_login.submit(options); }); $('#updraft-navtab-addons-content .wrap').on('keydown', '.updraftplus_com_login input', function (e) { if (13 == e.which) { e.preventDefault(); var email = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_email').val(); var password = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_password').val(); var auto_update = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_auto_updates').is(':checked') ? 1: 0; var auto_udc_connect = $('#updraft-navtab-addons-content .wrap .updraftplus_com_login #updraftplus-addons_options_auto_udc_connect').is(':checked') ? 1: 0; var options = { email: email, password: password, auto_update: auto_update, auto_udc_connect: auto_udc_connect }; updraftplus_com_login.submit(options); } }); $('#updraft-navtab-migrate-content').on('click', '.updraftclone_show_step_1', function (e) { $('.updraftplus-clone').addClass('opened'); $('.updraftclone_show_step_1').hide(); $('.updraft_migrate_widget_temporary_clone_stage1').show(); $('.updraft_migrate_widget_temporary_clone_stage0').hide(); }); $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_widget_temporary_clone_show_stage0', function(e) { e.preventDefault(); $('.updraft_migrate_widget_temporary_clone_stage0').toggle(); }); // First tab setup setup_migrate_tabs(); // hide section when clicking the close button $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_widget_module_content .close', function (e) { $('.updraft_migrate_intro').show(); $(this).closest('.updraft_migrate_widget_module_content').hide(); }); $('#updraft-navtab-migrate-content').on('click', '#updraft_migrate_tab_alt .close', function (e) { e.preventDefault(); $('.updraft_migrate_intro').show(); $('#updraft_migrate_tab_alt').html('').hide(); }); // Migrate show Add site button $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_add_site--trigger', function (e) { e.preventDefault(); $('.updraft_migrate_add_site').toggle(); }); $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_widget_module_content .updraftplus_com_login .ud_connectsubmit', function (e) { e.preventDefault(); var email = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_email').val(); var password = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_password').val(); var tfa = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_two_factor_code').val(); var consent = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login .temporary_clone_terms_and_conditions').is(':checked') ? 1 : 0; var options = { form_data: { email: email, password: password, two_factor_code: tfa, consent: consent } }; if (!email || !password) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login_status').html('' + updraftlion.error + ' ' + updraftlion.username_password_required).show(); } else { temporary_clone_submit(options); } }); $('#updraft-navtab-migrate-content').on('keydown', '.updraft_migrate_widget_module_content .updraftplus_com_login input', function (e) { if (13 == e.which) { e.preventDefault(); var email = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_email').val(); var password = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_password').val(); var tfa = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_two_factor_code').val(); var consent = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login .temporary_clone_terms_and_conditions').is(':checked') ? 1 : 0; var options = { form_data: { email: email, password: password, two_factor_code: tfa, consent: consent } }; if (!email || !password) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login_status').html('' + updraftlion.error + ' ' + updraftlion.username_password_required).show(); } else { temporary_clone_submit(options); } } }); $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_widget_module_content .updraftplus_com_key .ud_key_connectsubmit', function (e) { e.preventDefault(); var clone_key = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key #temporary_clone_options_key').val(); var consent = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key .temporary_clone_terms_and_conditions').is(':checked') ? 1 : 0; var options = { form_data: { clone_key: clone_key, consent: consent } }; if (!clone_key) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key_status').html('' + updraftlion.error + ' ' + updraftlion.clone_key_required).show(); } else { temporary_clone_key_submit(options); } }); $('#updraft-navtab-migrate-content').on('keydown', '.updraft_migrate_widget_module_content .updraftplus_com_key input', function (e) { if (13 == e.which) { e.preventDefault(); var clone_key = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key #temporary_clone_options_key').val(); var consent = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key .temporary_clone_terms_and_conditions').is(':checked') ? 1 : 0; var options = { form_data: { clone_key: clone_key, consent: consent } }; if (!clone_key) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key_status').html('' + updraftlion.error + ' ' + updraftlion.clone_key_required).show(); } else { temporary_clone_key_submit(options); } } }); $('#updraft-navtab-migrate-content').on('change', '.updraft_migrate_widget_module_content #updraftplus_clone_php_options', function () { var php_version = $(this).data('php_version'); var selected_version = $(this).val(); if (selected_version < php_version) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(updraftlion.clone_version_warning); } else { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(''); } }); $('#updraft-navtab-migrate-content').on('change', '.updraft_migrate_widget_module_content #updraftplus_clone_wp_options', function () { var wp_version = $(this).data('wp_version'); var selected_version = $(this).val(); if (selected_version < wp_version) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(updraftlion.clone_version_warning); } else { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(''); } }); $('#updraft-navtab-migrate-content').on('change', '.updraft_migrate_widget_module_content #updraftplus_clone_backup_options', function() { // reset the package list $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options > option').each(function() { var value = $(this).val(); if ('starter' == value) $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options option[value="'+value+'"]').prop('selected', true); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options option[value="'+value+'"]').prop("disabled", false); }); var clone_backup_select = $(this).find('option:selected'); if ('current' == $(clone_backup_select).data('nonce') || 'wp_only' == $(clone_backup_select).data('nonce')) return; var total_size = $(clone_backup_select).data('size'); // Disable packages that are to small for this backup set, then set the first available package as the selected option $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options > option').each(function() { var size = $(this).data('size'); var value = $(this).val(); if (total_size >= size) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options option[value="'+value+'"]').prop("disabled", true); } else { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options option[value="'+value+'"]').prop('selected', true); return false; } }); }); $('#updraft-navtab-migrate-content').on('click', '.updraft_migrate_widget_module_content #updraft_migrate_createclone', function (e) { e.preventDefault(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraft_migrate_createclone').prop('disabled', true); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(''); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_spinner.spinner').addClass('visible'); var clone_id = $(this).data('clone_id'); var secret_token = $(this).data('secret_token'); var php_version = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_php_options').val(); var wp_version = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_wp_options').val(); var region = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_region_options').val(); var package = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_package_options').val(); var updraftclone_branch = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_updraftclone_branch').val(); var updraftplus_branch = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_updraftplus_branch').val(); var admin_only = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_admin_login_options').is(':checked'); var use_queue = $('#updraftplus_clone_use_queue').is(':checked') ? 1 : 0; var db_anon_all = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_backupnow_db_anon_all').is(':checked') ? 1 : 0; var db_anon_non_staff = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_backupnow_db_anon_non_staff').is(':checked') ? 1 : 0; var db_anon_wc_orders = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_backupnow_db_anon_wc_order_data').is(':checked') ? 1 : 0; var backup_nonce = 'current'; var backup_timestamp = 'current'; var clone_backup_select_length = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_backup_options').length; var clone_backup_select = $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraftplus_clone_backup_options').find('option:selected'); if (0 !== clone_backup_select_length && 'undefined' !== typeof clone_backup_select) { backup_nonce = clone_backup_select.data('nonce'); backup_timestamp = clone_backup_select.data('timestamp'); } var options = { form_data: { clone_id: clone_id, secret_token: secret_token, install_info: { php_version: php_version, wp_version: wp_version, region: region, package: package, admin_only: admin_only, updraftclone_branch: ('undefined' === typeof updraftclone_branch) ? '' : updraftclone_branch, updraftplus_branch: ('undefined' === typeof updraftplus_branch) ? '' : updraftplus_branch, use_queue: ('undefined' === typeof use_queue) ? 1 : use_queue } } }; var backup_options = { db_anon_all: db_anon_all, db_anon_non_staff: db_anon_non_staff, db_anon_wc_orders: db_anon_wc_orders, clone_region: region } if ('wp_only' === backup_nonce) { options['form_data']['install_info']['wp_only'] = 1; } temporary_clone_process_create(options, backup_timestamp, backup_nonce, backup_options); }); // Create a updraftplus_com_login object, to store functions and variables var updraftplus_com_login = {}; updraftplus_com_login.set_status = function(status) { $('#updraft-navtab-addons-content .wrap').find('.updraftplus_spinner.spinner').text(status); } updraftplus_com_login.show_loader = function() { $('#updraft-navtab-addons-content .wrap').find('.updraftplus_spinner.spinner').addClass('visible'); $('#updraft-navtab-addons-content .wrap').find('.ud_connectsubmit').prop('disabled', 'disabled'); } updraftplus_com_login.hide_loader = function() { $('#updraft-navtab-addons-content .wrap').find('.updraftplus_spinner.spinner').removeClass('visible').text(updraftlion.processing); $('#updraft-navtab-addons-content .wrap').find('.ud_connectsubmit').prop('disabled', false); } /* This function will send an AJAX request to the backend to check the users credentials, then it will either inform the user of any errors or if there are none it will submit the form. @param {array} options - an array that includes the users email and password */ updraftplus_com_login.submit = function(options) { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html('').hide(); if (this.stage) { switch (this.stage) { case 'connect_udc': case 'connect_udc_TFA': // update data in object var email = $('#updraftplus-addons_options_email').val(); var password = $('#updraftplus-addons_options_password').val(); this.login_data.email = email; this.login_data.password = password; // connect_udc again this.connect_udc(); break; case 'create_key': this.create_key(); break; default: this.stage = null; updraftplus_com_login.submit(); break; } return; } this.set_status(updraftlion.connecting); this.show_loader(); updraft_send_command('updraftplus_com_login_submit', { data: options, }, function (response) { if (response.hasOwnProperty('success')) { // logged in was successful, so create a key if the checkbox was checked. if ($('#updraftplus-addons_options_auto_udc_connect').is(':checked')) { this.login_data = { email: options.email, password: options.password, i_consent: 1, two_factor_code: '' }; // CREATE KEY updraftplus_com_login.create_key(); } else { updraftplus_com_login.hide_loader(); $('#updraft-navtab-addons-content .wrap .updraftplus_com_login').trigger('submit'); } } else if (response.hasOwnProperty('error')) { updraftplus_com_login.hide_loader(); $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(response.message).show(); } }.bind(this)); } updraftplus_com_login.create_key = function() { this.stage = 'create_key'; this.set_status(updraftlion.udc_cloud_connected); this.show_loader(); var command_data = { where_send: '__updraftpluscom', key_description: '', key_size: null, mothership_firewalled: 0 }; // updraftcentral_cloud_show_spinner(modal); updraft_send_command('updraftcentral_create_key', command_data, function(response) { // updraftcentral_cloud_hide_spinner(modal); try { var data = ud_parse_json(response); if (data.hasOwnProperty('error')) { console.log(data); return; } if (data.hasOwnProperty('bundle')) { console.log('bundle', data.bundle); this.login_data.key = data.bundle, this.stage = 'connect_udc'; updraftplus_com_login.connect_udc(); } else { if (data.hasOwnProperty('r')) { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(updraftlion.trouble_connecting).show(); alert(data.r); } else { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(updraftlion.trouble_connecting).show(); console.log(data); } updraftplus_com_login.hide_loader(); } } catch (err) { console.log(err); updraftplus_com_login.hide_loader(); } }.bind(this), { json_parse: false }); } updraftplus_com_login.connect_udc = function() { var container = $('#updraft-navtab-addons-content .wrap'); updraftplus_com_login.set_status(updraftlion.udc_cloud_key_created); updraftplus_com_login.show_loader(); if ('connect_udc_TFA' == this.stage) { this.login_data.two_factor_code = container.find('input#updraftplus-addons_options_two_factor_code').val(); updraftplus_com_login.set_status(updraftlion.checking_tfa_code); } var login_data = { form_data: this.login_data }; login_data.form_data.addons_options_connect = 1; // Final step, connect UDC with the Key and all. updraft_send_command('process_updraftcentral_login', login_data, function(login_response) { try { var data = ud_parse_json(login_response); if (data.hasOwnProperty('error')) { if ('incorrect_password' === data.code) { container.find('.tfa_fields').hide(); container.find('.non_tfa_fields').show(); container.find('input#updraftplus-addons_options_two_factor_code').val(''); container.find('input#updraftplus-addons_options_password').val('').trigger('focus'); } if ('no_key_found' === data.code) { this.stage = 'create_key'; } // Continue with UpdraftPlus account even if the user has used all UpdraftCentral licences if ('no_licences_available' === data.code) { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(updraftlion.login_udc_no_licences_short).show(); data.status = 'authenticated'; container.find('input[name="_wp_http_referer"]').val(function(index, val) { return val + '&udc_connect=0'; }); } else { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(data.message).show(); $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').find('a').attr('target', '_blank'); console.log(data); updraftplus_com_login.hide_loader(); return; } } if (data.hasOwnProperty('tfa_enabled') && true == data.tfa_enabled) { $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html('').hide(); container.find('.non_tfa_fields').hide(); container.find('.tfa_fields').show(); container.find('input#updraftplus-addons_options_two_factor_code').trigger('focus'); this.stage = 'connect_udc_TFA'; } if ('authenticated' === data.status) { container.find('.non_tfa_fields').hide(); container.find('.tfa_fields').hide(); container.find('.updraft-after-form-table').hide(); this.stage = null; $('#updraft-navtab-addons-content .wrap .updraftplus_com_login_status').html(updraftlion.login_successful_short).show().addClass('success'); // submit the form (to reload the page). setTimeout(function() { $('#updraft-navtab-addons-content .wrap form.updraftplus_com_login').trigger('submit'); }, 1000); } } catch (err) { console.log(err); } updraftplus_com_login.hide_loader(); }.bind(this), { json_parse: false }); } /** * This function will send an AJAX request to the backend to check the users credentials, then it will either inform the user of any errors or display UI elements that include their token count and a way to create new clones. * * @param {array} options - an array that includes the users email and password */ function temporary_clone_submit(options) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login_status').html('').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login .updraftplus_spinner.spinner').addClass('visible'); updraft_send_command('process_updraftplus_clone_login', options, function (response) { try { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login .updraftplus_spinner.spinner').removeClass('visible'); if (response.hasOwnProperty('status') && 'error' == response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login_status').html(response.message).show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .tfa_fields').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .non_tfa_fields').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_login #temporary_clone_options_two_factor_code').val(''); return; } if (response.hasOwnProperty('tfa_enabled') && true == response.tfa_enabled) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .non_tfa_fields').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .tfa_fields').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 input#temporary_clone_options_two_factor_code').trigger('focus'); } if ('authenticated' === response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .non_tfa_fields').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 .tfa_fields').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1 input#temporary_clone_options_two_factor_code').val(''); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').html(response.html); if (response.hasOwnProperty('clone_info') && response.clone_info.hasOwnProperty('expires_after')) temporary_clone_timer(response.clone_info.expires_after); } } catch (err) { console.log(err); } }); } /** * This function will send an AJAX request to the backend to check the clone key, then it will either inform the user of any errors or display UI elements that include their token count and a way to create new clones. * * @param {array} options - an array that includes the clone key */ function temporary_clone_key_submit(options) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key_status').html('').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key .updraftplus_spinner.spinner').addClass('visible'); updraft_send_command('process_updraftplus_clone_login', options, function (response) { try { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key .updraftplus_spinner.spinner').removeClass('visible'); if (response.hasOwnProperty('status') && 'error' == response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_com_key_status').html(response.message).show(); return; } if ('authenticated' === response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').html(response.html); if (response.hasOwnProperty('clone_info') && response.clone_info.hasOwnProperty('expires_after')) temporary_clone_timer(response.clone_info.expires_after); } } catch (err) { console.log(err); } }); } /** * This function will add a timer to reset the UI if the user does not create the clone before it expires * * @param {integer} expires_after - the clone expires time in seconds */ function temporary_clone_timer(expires_after) { // the expires_after time is in seconds we need it in milliseconds for the setTimeout function var timeout = expires_after * 1000; temporary_clone_timeout = setTimeout(function () { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').html(''); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage1').show(); }, timeout); } /** * This function will check if we are using an existing backup and if anything needs downloading before proceeding to process the clone create command * * @param {array} options - an array of options to create the clone * @param {string} backup_timestamp - the timestamp of the backup we want to use or 'current' to create a new backup * @param {string} backup_nonce - the backup nonce of the backup we want to use or 'current' to create a new backup * @param {array} backup_options - an array of options for the backup */ function temporary_clone_process_create(options, backup_timestamp, backup_nonce, backup_options) { var which_to_download = ''; if ('current' != backup_timestamp) { updraft_send_command('whichdownloadsneeded', { updraftplus_clone: true, timestamp: backup_timestamp }, function (response) { if (response.hasOwnProperty('downloads')) { console.log('UpdraftPlus: items which still require downloading follow'); which_to_download = response.downloads; console.log(which_to_download); } // Kick off any downloads, if needed if (0 == which_to_download.length) return; for (var i = 0; i < which_to_download.length; i++) { // updraft_downloader(base, backup_timestamp, what, whicharea, set_contents, prettydate, async) updraft_downloader('udclonedlstatus_', backup_timestamp, which_to_download[i][0], '#ud_downloadstatus3', which_to_download[i][1], '', false); } }, { alert_on_error: false, error_callback: function (response, status, error_code, resp) { if (typeof resp !== 'undefined' && resp.hasOwnProperty('fatal_error')) { console.error(resp.fatal_error_message); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html('' + resp.fatal_error_message + '
'); } else { var error_message = "updraft_send_command: error: " + status + " (" + error_code + ")"; $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html('' + error_message + '
'); console.log(error_message); console.log(response); } } }); } setTimeout(function () { if (0 != which_to_download.length) { temporary_clone_process_create(options, backup_timestamp, backup_nonce, backup_options); return; } var clone_id = options['form_data']['clone_id']; var secret_token = options['form_data']['secret_token']; updraft_send_command('process_updraftplus_clone_create', options, function (response) { try { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraft_migrate_createclone').prop('disabled', false); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_spinner.spinner').removeClass('visible'); if (response.hasOwnProperty('status') && 'error' == response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(updraftlion.error + ' ' + response.message).show(); return; } if ('success' === response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage2').hide(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage3').show(); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraft_migrate_widget_temporary_clone_stage3').html(response.html); // remove the clone timeout as the clone has now been created if (temporary_clone_timeout) clearTimeout(temporary_clone_timeout); // check if the response includes a secret token, if it does we have claimed a clone from the queue and need to update our current secret token to the one that belongs to the claimed clone if (response.hasOwnProperty('secret_token')) { secret_token = response.secret_token; } if ('wp_only' === backup_nonce) { jQuery('#updraft_clone_progress .updraftplus_spinner.spinner').addClass('visible'); temporary_clone_poll(clone_id, secret_token); } else { jQuery('#updraft_clone_progress .updraftplus_spinner.spinner').addClass('visible'); temporary_clone_boot_backup(clone_id, secret_token, response.url, response.key, backup_nonce, backup_timestamp, backup_options); } } } catch (err) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraft_migrate_createclone').prop('disabled', false); console.log("Error when processing the response of process_updraftplus_clone_create (as follows)"); console.log(err); } }); }, 5000); } /** * This function will send an AJAX request to the backend to start a clone backup job * * @param {string} clone_id - the clone id * @param {string} secret_token - the clone secret * @param {string} clone_url - the clone url * @param {string} key - the migration key * @param {string} backup_nonce - the nonce for the backup we want to use or 'current' for a fresh backup * @param {string} backup_timestamp - the timestamp for the backup we want to use or 'current' for a fresh backup * @param {array} backup_options - an array of options for the backup */ function temporary_clone_boot_backup(clone_id, secret_token, clone_url, key, backup_nonce, backup_timestamp, backup_options) { var params = { updraftplus_clone_backup: 1, backupnow_nodb: 0, backupnow_nofiles: 0, backupnow_nocloud: 0, backupnow_label: 'UpdraftClone', extradata: '', onlythisfileentity: 'plugins,themes,uploads,others', clone_id: clone_id, secret_token: secret_token, clone_url: clone_url, key: key, backup_nonce: backup_nonce, backup_timestamp: backup_timestamp, db_anon_all: backup_options['db_anon_all'], db_anon_non_staff: backup_options['db_anon_non_staff'], db_anon_wc_orders: backup_options['db_anon_wc_orders'], clone_region: backup_options['clone_region'] }; updraft_activejobslist_backupnownonce_only = 1; updraft_send_command('backupnow', params, function (response) { jQuery('#updraft_clone_progress .updraftplus_spinner.spinner').removeClass('visible'); jQuery('#updraft_backup_started').html(response.m); if (response.hasOwnProperty('nonce')) { // Can't return it from this context updraft_backupnow_nonce = response.nonce; updraft_clone_jobs.push(updraft_backupnow_nonce); updraft_inpage_success_callback = function () { jQuery('#updraft_clone_activejobsrow').hide(); // If user aborts the job if (updraft_aborted_jobs[updraft_backupnow_nonce]) { jQuery('#updraft_clone_progress').html(updraftlion.clone_backup_aborted); } else { jQuery('#updraft_clone_progress').html(updraftlion.clone_backup_complete); } }; console.log("UpdraftPlus: ID of started job: " + updraft_backupnow_nonce); } updraft_activejobs_update(true); }); } /** * This function will send an AJAX request to the backend to poll for the clones install information * * @param {string} clone_id - the clone id * @param {string} secret_token - the clone secret */ function temporary_clone_poll(clone_id, secret_token) { var options = { clone_id: clone_id, secret_token: secret_token, }; setTimeout(function () { updraft_send_command('process_updraftplus_clone_poll', options, function (response) { if (response.hasOwnProperty('status')) { if ('error' == response.status) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_clone_status').html(updraftlion.error + ' ' + response.message).show(); return; } if ('success' === response.status) { if (response.hasOwnProperty('data') && response.data.hasOwnProperty('wordpress_credentials')) { $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content .updraftplus_spinner.spinner').removeClass('visible'); $('#updraft-navtab-migrate-content .updraft_migrate_widget_module_content #updraft_clone_progress').append(''+error_message+'
'); console.log(error_message); console.log(response); } } }); } catch (err) { console.log("UpdraftPlus: error (follows) when looking for items needing downloading"); console.log(err); alert(updraftlion.jsonnotunderstood); } // Make sure all are downloaded } else if (2 == updraft_restore_stage) { updraft_restorer_checkstage2(1); } else if (3 == updraft_restore_stage) { var continue_restore = 1; jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', true); $('#updraft_restoreoptions_ui input.required').each(function(index) { if (continue_restore == 0) return; var sitename = $(this).val(); if (sitename == '') { alert(updraftlion.pleasefillinrequired); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); continue_restore = 0; } else if ($(this).attr('pattern') != '') { var pattern = $(this).attr('pattern'); var re = new RegExp(pattern, "g"); if (!re.test(sitename)) { alert($(this).data('invalidpattern')); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); continue_restore = 0; } } }); if (1 == dbselected) { anyselected = 0; jQuery('input[name="updraft_restore_tables_options[]"').each(function (x, y) { if (jQuery(y).is(':checked') && !jQuery(y).is(':disabled')) anyselected = 1; }); if (0 == anyselected && !skipped_db_scan) { alert(updraftlion.youdidnotselectany); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); return; } } if (1 == pluginselected) { anyselected = 0; if (!jQuery(".updraftplus_restore_plugins_options_container").length) anyselected = 1; jQuery('input[name="updraft_restore_plugins_options[]"').each(function (x, y) { if (jQuery(y).is(':checked') && !jQuery(y).is(':disabled')) anyselected = 1; }); if (0 == anyselected) { alert(updraftlion.youdidnotselectany); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); return; } } if (1 == themeselected) { anyselected = 0; if (!jQuery(".updraftplus_restore_themes_options_container").length) anyselected = 1; jQuery('input[name="updraft_restore_themes_options[]"').each(function (x, y) { if (jQuery(y).is(':checked') && !jQuery(y).is(':disabled')) anyselected = 1; }); if (0 == anyselected) { alert(updraftlion.youdidnotselectany); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); return; } } if (1 == moreselected) { anyselected = 0; jQuery('input[name="updraft_include_more_index[]"').each(function (x, y) { if (jQuery(y).is(':checked') && !jQuery(y).is(':disabled')) { anyselected = 1; if ('' == jQuery('#updraft_include_more_path_restore' + x).val()) { alert(updraftlion.emptyrestorepath); } } }); if (0 == anyselected) { alert(updraftlion.youdidnotselectany); jQuery('.updraft-restore--next-step, .updraft-restore--cancel').prop('disabled', false); return; } } if (!continue_restore) return; var restore_options = $('#updraft_restoreoptions_ui select, #updraft_restoreoptions_ui input').serialize(); // jQuery serialize does not pick up unchecked checkboxes, but we want to include these so that we have a list of table/plugins/themes the user does not want to restore we prepend these with udp-skip-{entity}- and check this on the backend var entities = ['table', 'plugins', 'themes']; jQuery.each(entities, function(i, entity) { jQuery.each(jQuery('input[name="updraft_restore_' + entity + '_options[]').filter(function(idx) { return jQuery(this).prop('checked') === false }), function(idx, el) { restore_options += '&' + jQuery(el).attr('name') + '=' + 'udp-skip-' + entity + '-' + jQuery(el).val(); }); }) console.log("Restore options: "+restore_options); if (typeof php_max_input_vars !== 'undefined') { var restore_options_length = restore_options.split("&").length; var warning_template_start = '' + updraftlion.warnings +'
'+resp.fatal_error_message+'
'); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; jQuery('#updraft_zip_files_jstree').html(''+error_message+'
'); console.log(error_message); alert(error_message); console.log(response); } } }); }, "error": function(error) { alert(error); console.log(error); }, }, "search": { "show_only_matches": true }, "plugins": ["sort"], }); } else if ('contain-clause' == panel) { jQuery('#updraft_exclude_files_folders_wildcards_jstree').jstree({ "core": { "multiple": false, "data": function (nodeid, callback) { updraft_send_command('get_jstree_directory_nodes', {entity: 'filebrowser', directories_only: 1, node:nodeid, path: jQuery('#updraft_exclude_modal_path').val(), findex: 0, skip_root_node: 0}, function(response) { if (response.hasOwnProperty('error')) { alert(response.error); } else { callback.call(this, response.nodes); } }, { error_callback: function(response, status, error_code, resp) { if (typeof resp !== 'undefined' && resp.hasOwnProperty('fatal_error')) { console.error(resp.fatal_error_message); jQuery('#updraft_zip_files_jstree').html(''+resp.fatal_error_message+'
'); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; jQuery('#updraft_zip_files_jstree').html(''+error_message+'
'); console.log(error_message); alert(error_message); console.log(response); } } }); }, "error": function(error) { alert(error); console.log(error); }, }, "search": { "show_only_matches": true }, "plugins": ["sort"], }); } jQuery('#updraft_exclude_modal_main').slideUp(); jQuery('.updraft-exclude-panel').hide(); jQuery('.updraft-exclude-panel[data-panel='+panel+']').slideDown(); }); jQuery('.updraft-exclude-modal-reset').on('click', function(event) { event.preventDefault(); jQuery('#updraft_exclude_files_folders_jstree').jstree("destroy"); jQuery('#updraft_exclude_files_folders_wildcards_jstree').jstree("destroy"); jQuery('#updraft_exclude_extension_field').val(''); jQuery('#updraft_exclude_prefix_field').val(''); jQuery('.updraft-exclude-panel').slideUp(); jQuery('#updraft_exclude_modal_main').slideDown(); }); jQuery('.updraft-exclude-submit').on('click', function() { var panel = jQuery(this).data('panel'); var exclude_item_val = ''; switch (panel) { case 'file-dir': var exclude_jstree_selected = jQuery("#updraft_exclude_files_folders_jstree").jstree("get_selected"); if (0 == exclude_jstree_selected.length) { alert(updraftlion.exclude_select_file_or_folder_msg); return; } var selected_file_or_folder = exclude_jstree_selected[0]; var prefix_path = jQuery('#updraft_exclude_modal_path').val(); if (selected_file_or_folder.substr(0, prefix_path.length) == prefix_path) { selected_file_or_folder = selected_file_or_folder.substr(prefix_path.length, selected_file_or_folder.length); } if ('/' == selected_file_or_folder.charAt(0)) selected_file_or_folder = selected_file_or_folder.substr(1); if ('/' == selected_file_or_folder.charAt(selected_file_or_folder.length - 1)) selected_file_or_folder = selected_file_or_folder.substr(0, selected_file_or_folder.length - 1); exclude_item_val = selected_file_or_folder; break; case 'extension': var exclude_extension = jQuery('#updraft_exclude_extension_field').val(); if ('' == exclude_extension) { alert(updraftlion.exclude_type_ext_msg); return; } if (!exclude_extension.match(/^[0-9a-zA-Z]+$/)) { alert(updraftlion.exclude_ext_error_msg); return; } exclude_item_val = 'ext:'+exclude_extension; break; case 'begin-with': var prefix = jQuery('#updraft_exclude_prefix_field').val(); if ('' == prefix) { alert(updraftlion.exclude_type_prefix_msg); return; } if (!prefix.match(/^\s*[a-z-_\d,\s]+\s*$/i)) { alert(updraftlion.exclude_prefix_error_msg); return; } exclude_item_val = 'prefix:'+prefix; break; case 'contain-clause': var exclude_jstree_selected = jQuery("#updraft_exclude_files_folders_wildcards_jstree").jstree("get_selected"); if (0 == exclude_jstree_selected.length) { alert(updraftlion.exclude_select_folder_wildcards_msg); return; } var clause_val = jQuery(this).parents('div.updraft-exclude-panel').find('div.clause-input-container input').val(); jQuery(this).parents('div.updraft-exclude-panel').find('div.clause-input-container input').val(''); var clause_type = jQuery(this).parents('div.updraft-exclude-panel').find('div.clause-input-container select').val(); if ('' == clause_val) { alert(updraftlion.exclude_contain_error_msg); return; } jQuery(this).parents('div.updraft-exclude-panel').find('div.clause-input-container select option').eq(0).prop('selected', true); var selected_file_or_folder = exclude_jstree_selected[0]; var prefix_path = jQuery('#updraft_exclude_modal_path').val(); if (selected_file_or_folder.substr(0, prefix_path.length) == prefix_path) { selected_file_or_folder = selected_file_or_folder.substr(prefix_path.length, selected_file_or_folder.length); } if ('/' == selected_file_or_folder.charAt(0)) selected_file_or_folder = selected_file_or_folder.substr(1); if ('/' == selected_file_or_folder.charAt(selected_file_or_folder.length - 1)) selected_file_or_folder = selected_file_or_folder.substr(0, selected_file_or_folder.length - 1); exclude_item_val = selected_file_or_folder; if ('' !== exclude_item_val) exclude_item_val += '/'; clause_val = clause_val.replace(/\*/g, '\\*'); if ('beginning' === clause_type) { exclude_item_val += clause_val + '*'; } else if ('middle' === clause_type) { exclude_item_val += '*' + clause_val + '*'; } else if ('end' === clause_type) { exclude_item_val += '*' + clause_val; } break; default: return; } var include_backup_file = jQuery('#updraft_exclude_modal_for').val(); if (!updraft_is_unique_exclude_rule(exclude_item_val, include_backup_file)) return; var exclude_entity_html = ''; jQuery('.updraft_exclude_entity_container[data-include-backup-file="' + include_backup_file + '"]').append(exclude_entity_html); updraft_exclude_entity_update(include_backup_file); jQuery('#updraft_exclude_modal').dialog('close'); }); // TODO: This is suspected to be obsolete. Confirm + remove. jQuery('#updraft-navtab-settings-content .updraft-service').on('change', function() { var active_class = jQuery(this).val(); jQuery('#updraft-navtab-settings-content .updraftplusmethod').hide(); jQuery('#updraft-navtab-settings-content .'+active_class).show(); }); jQuery('#updraft-navtab-settings-content a.updraft_show_decryption_widget').on('click', function(e) { e.preventDefault(); jQuery('#updraftplus_db_decrypt').val(jQuery('#updraft_encryptionphrase').val()); jQuery('#updraft-manualdecrypt-modal').slideToggle(); }); jQuery('#updraftplus-phpinfo').on('click', function(e) { e.preventDefault(); updraft_iframe_modal('phpinfo', updraftlion.phpinfo); }); jQuery('#updraftplus-rawbackuphistory').on('click', function(e) { e.preventDefault(); updraft_iframe_modal('rawbackuphistory', updraftlion.raw); }); // + Added addons navtab jQuery('#updraft-navtab-status').on('click', function(e) { e.preventDefault(); updraft_open_main_tab('status'); updraft_page_is_visible = 1; updraft_console_focussed_tab = 'status'; // Refresh the console, as its next update might be far away updraft_activejobs_update(true); }); jQuery('#updraft-navtab-expert').on('click', function(e) { e.preventDefault(); updraft_open_main_tab('expert'); updraft_page_is_visible = 1; }); jQuery('#updraft-navtab-settings, #updraft-navtab-settings2, #updraft_backupnow_gotosettings').on('click', function(e) { e.preventDefault(); // These next two should only do anything if the relevant selector was clicked jQuery(this).parents('.updraftmessage').remove(); jQuery('#updraft-backupnow-modal').dialog('close'); updraft_open_main_tab('settings'); updraft_page_is_visible = 1; }); jQuery('#updraft-navtab-addons').on('click', function(e) { e.preventDefault(); jQuery(this).addClass('b#nav-tab-active'); updraft_open_main_tab('addons'); updraft_page_is_visible = 1; }); jQuery('#updraft-navtab-backups').on('click', function(e) { e.preventDefault(); updraft_console_focussed_tab = 'backups'; updraft_historytimertoggle(1); updraft_open_main_tab('backups'); }); jQuery('#updraft-navtab-migrate').on('click', function(e) { e.preventDefault(); jQuery('#updraft_migrate_tab_alt').html('').hide(); updraft_open_main_tab('migrate'); updraft_page_is_visible = 1; if (!jQuery('#updraft_migrate .updraft_migrate_widget_module_content').is(':visible')) { jQuery('.updraft_migrate_intro').show(); } }); if ('migrate' == updraftlion.tab) jQuery('#updraft-navtab-migrate').trigger('click'); updraft_send_command('ping', null, function(data, response) { if ('success' == response && data != 'pong' && data.indexOf('pong')>=0) { jQuery('#updraft-navtab-backups-content .ud-whitespace-warning').show(); console.log("UpdraftPlus: Extra output warning: response (which should be just (string)'pong') follows."); console.log(data); } }, { json_parse: false, type: 'GET' }); // Section: Plupload try { if (typeof updraft_plupload_config !== 'undefined') { plupload_init(); } } catch (err) { console.log(err); } function plupload_init() { // create the uploader and pass the config from above var uploader = new plupload.Uploader(updraft_plupload_config); // checks if browser supports drag and drop upload, makes some css adjustments if necessary uploader.bind('Init', function(up) { var uploaddiv = jQuery('#plupload-upload-ui'); if (up.features.dragdrop) { uploaddiv.addClass('drag-drop'); jQuery('#drag-drop-area') .on('dragover.wp-uploader', function() { uploaddiv.addClass('drag-over'); }) .on('dragleave.wp-uploader, drop.wp-uploader', function() { uploaddiv.removeClass('drag-over'); }); } else { uploaddiv.removeClass('drag-drop'); jQuery('#drag-drop-area').off('.wp-uploader'); } }); uploader.init(); // a file was added in the queue uploader.bind('FilesAdded', function(up, files) { if ($('#updraft-plupload-modal').is(':hidden')) { $('#updraft-plupload-modal').slideToggle(); } // var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); plupload.each(files, function(file) { // @codingStandardsIgnoreLine if (! /^backup_([\-0-9]{15})_.*_([0-9a-f]{12})-[\-a-z]+([0-9]+?)?(\.(zip|gz|gz\.crypt))?$/i.test(file.name) && ! /^log\.([0-9a-f]{12})\.txt$/.test(file.name)) { var accepted_file = false; for (var i = 0; i'+resp.r+''); } else { console.log(resp); } }, { type: 'GET' }); } jQuery('#updraft_activejobs_table, #updraft-navtab-migrate-content').on('click', '.updraft_jobinfo_delete', function(e) { e.preventDefault(); var job_id = jQuery(this).data('jobid'); if (job_id) { $(this).addClass('disabled'); updraft_activejobs_delete(job_id); } else { console.log("UpdraftPlus: A stop job link was clicked, but the Job ID could not be found"); } }); jQuery('#updraft_activejobs_table, #updraft-navtab-backups-content .updraft_existing_backups, #updraft-backupnow-inpage-modal, #updraft-navtab-migrate-content').on('click', '.updraft-log-link', function(e) { e.preventDefault(); var file_id = jQuery(this).data('fileid'); var job_id = jQuery(this).data('jobid'); if (file_id) { updraft_popuplog(file_id); } else if (job_id) { updraft_popuplog(job_id); } else { console.log("UpdraftPlus: A log link was clicked, but the Job ID could not be found"); } }); function updraft_restore_setup(entities, key, show_data) { updraft_restore_setoptions(entities); jQuery('#updraft_restore_timestamp').val(key); jQuery('.updraft_restore_date').html(show_data); updraft_restore_stage = 1; // jQuery('#updraft-restore-modal').dialog('open'); updraft_restore_modal.open(); updraft_activejobs_update(true); } jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', 'button.choose-components-button', function(e) { var entities = jQuery(this).data('entities'); var backup_timestamp = jQuery(this).data('backup_timestamp'); var show_data = jQuery(this).data('showdata'); updraft_restore_setup(entities, backup_timestamp, show_data); }); /** * Get the value of a named URL parameter - https://stackoverflow.com/questions/4548487/jquery-read-query-string * * @param {string} name - URL parameter to return the value of * * @returns {string} */ function get_parameter_by_name(name) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex_s = "[\\?&]"+name+"=([^]*)"; var regex = new RegExp(regex_s); var results = regex.exec(window.location.href); if (results == null) { return ''; } else { return decodeURIComponent(results[1].replace(/\+/g, ' ')); } } if (get_parameter_by_name('udaction') == 'initiate_restore') { var entities = get_parameter_by_name('entities'); var backup_timestamp = get_parameter_by_name('backup_timestamp'); var show_data = get_parameter_by_name('showdata'); updraft_restore_setup(entities, backup_timestamp, show_data); } var updraft_upload_modal_buttons = {}; updraft_upload_modal_buttons[updraftlion.uploadbutton] = function () { var key = jQuery('#updraft_upload_timestamp').val(); var nonce = jQuery('#updraft_upload_nonce').val(); var services = ''; var send_list = false; jQuery('.updraft_remote_storage_destination').each(function (index) { if (jQuery(this).is(':checked')) { send_list = true; } }); if (!send_list) { jQuery('#updraft-upload-modal-error').html(updraftlion.local_upload_error); return; } else { services = jQuery("input[name^='updraft_remote_storage_destination_']").serializeArray(); } jQuery(this).dialog("close"); alert(updraftlion.local_upload_started); updraft_send_command('upload_local_backup', { use_nonce: nonce, use_timestamp: key, services: services }); }; updraft_upload_modal_buttons[updraftlion.cancel] = function () { jQuery(this).dialog("close"); }; jQuery("#updraft-upload-modal").dialog({ autoOpen: false, modal: true, resizeOnWindowResize: true, scrollWithViewport: true, resizeAccordingToViewport: true, useContentSize: false, open: function(event, ui) { $(this).parent().trigger('focus'); $(this).dialog('option', 'width', 308); if (jQuery(window).height() > 460) { $(this).dialog('option', 'height', 318); } else if (jQuery(window).height() > 250 && jQuery(window).height() < 461) { $(this).dialog('option', 'height', 460); } else { $(this).dialog('option', 'height', jQuery(window).height() - 20); } }, buttons: updraft_upload_modal_buttons }); jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', 'button.updraft-upload-link', function (e) { e.preventDefault(); var nonce = jQuery(this).data('nonce').toString(); var key = jQuery(this).data('key').toString(); var services = jQuery(this).data('services').toString(); if (nonce) { updraft_upload(key, nonce, services); } else { console.log("UpdraftPlus: A upload link was clicked, but the Job ID could not be found"); } }); jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', '.updraft-load-more-backups', function (e) { e.preventDefault(); var backup_count = parseInt(jQuery('#updraft-navtab-backups-content .updraft_existing_backups .updraft_existing_backups_row').length) + parseInt(updraftlion.existing_backups_limit); updraft_updatehistory(0, 0, 0, backup_count); }); jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', '.updraft-load-all-backups', function (e) { e.preventDefault(); updraft_updatehistory(0, 0, 0, 9999999); }); /** * Opens the dialog box for confirmation of where to upload the backup * * @param {string} key - The UNIX timestamp of the backup * @param {string} nonce - The backup job ID * @param {string} services - A list of services that have not been uploaded to yet */ function updraft_upload(key, nonce, services) { jQuery('#updraft_upload_timestamp').val(key); jQuery('#updraft_upload_nonce').val(nonce); var services_array = services.split(","); jQuery('.updraft_remote_storage_destination').each(function (index) { var name = jQuery(this).val(); if (jQuery.inArray(name, services_array) == -1) { jQuery(this).prop('checked', false); jQuery(this).prop('disabled', true); var label = $(this).prop("labels"); jQuery(label).find('span').show(); } }); jQuery('#updraft-upload-modal').dialog('open'); } jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', '.updraft-delete-link', function(e) { e.preventDefault(); var hasremote = jQuery(this).data('hasremote'); var nonce = jQuery(this).data('nonce').toString(); var key = jQuery(this).data('key').toString(); if (nonce) { updraft_delete(key, nonce, hasremote); } else { console.log("UpdraftPlus: A delete link was clicked, but the Job ID could not be found"); } }); jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('click', 'button.updraft_download_button', function(e) { e.preventDefault(); var base = 'uddlstatus_'; var backup_timestamp = jQuery(this).data('backup_timestamp'); var what = jQuery(this).data('what'); var whicharea = '.ud_downloadstatus'; var set_contents = jQuery(this).data('set_contents'); var prettydate = jQuery(this).data('prettydate'); var async = true; updraft_downloader(base, backup_timestamp, what, whicharea, set_contents, prettydate, async); }); jQuery('#updraft-navtab-backups-content .updraft_existing_backups').on('dblclick', '.updraft_existingbackup_date', function (e) { e.preventDefault(); var nonce = jQuery(this).data('nonce').toString(); var timestamp = jQuery(this).data('timestamp').toString(); updraft_send_command('rawbackup_history', { timestamp: timestamp, nonce: nonce }, function (response) { if (response.hasOwnProperty('rawbackup')) { var textArea = document.createElement('textarea'); textArea.innerHTML = response.rawbackup; updraft_html_modal(textArea.value, updraftlion.raw, 780, 500); } else { updraft_html_modal(updraftlion.jsonnotunderstood, updraftlion.raw, 780, 500); } }, { type: 'POST' }); updraft_html_modal('
'+resp.e+'
', updraftlion.disconnect, 400, 250); if (resp.hasOwnProperty('code') && resp.code == 'no_quota') { $(settings_css_prefix+'#updraftvault_settings_connect').slideUp(); $(settings_css_prefix+'#updraftvault_settings_default').slideDown(); } } else if (resp.hasOwnProperty('connected') && resp.connected && resp.hasOwnProperty('html')) { $(settings_css_prefix+'#updraftvault_settings_connect').slideUp(); $(settings_css_prefix+'#updraftvault_settings_connected').html(resp.html).slideDown(); } else { console.log(resp); alert(updraftlion.unexpectedresponse+' '+response); } }, { error_callback: function(response, status, error_code, resp) { $(settings_css_prefix+'#updraftvault_connect_go').html(updraftlion.connect); if (typeof resp !== 'undefined' && resp.hasOwnProperty('fatal_error')) { console.error(resp.fatal_error_message); alert(resp.fatal_error_message); } else { var error_message = "updraft_send_command: error: "+status+" ("+error_code+")"; console.log(error_message); alert(error_message); console.log(response); } } }); return false; }); // Mark a backup as always keep (do not delete) $('#updraft-iframe-modal').on('change', '#always_keep_this_backup', function() { var backup_key = $(this).data('backup_key'); var params = { backup_key: backup_key, always_keep: $(this).is(':checked') ? 1 : 0, }; updraft_send_command('always_keep_this_backup', params, function(resp) { if (resp.hasOwnProperty('rawbackup')) { jQuery('#updraft-iframe-modal').dialog('close'); jQuery('.updraft_existing_backups_row_'+backup_key+' .updraft_existingbackup_date').data('rawbackup', resp.rawbackup); updraft_html_modal(jQuery('.updraft_existing_backups_row_'+backup_key+' .updraft_existingbackup_date').data('rawbackup'), updraftlion.raw, 780, 500); } }); }); }); // End ready Vault // Next: the encrypted database pluploader jQuery(function($) { try { if (typeof updraft_plupload_config2 !== 'undefined') { plupload_init(); } } catch (err) { console.log(err); } function plupload_init() { // create the uploader and pass the config from above var uploader = new plupload.Uploader(updraft_plupload_config2); // checks if browser supports drag and drop upload, makes some css adjustments if necessary uploader.bind('Init', function(up) { var uploaddiv = jQuery('#plupload-upload-ui2'); if (up.features.dragdrop) { uploaddiv.addClass('drag-drop'); jQuery('#drag-drop-area2') .on('dragover.wp-uploader', function() { uploaddiv.addClass('drag-over'); }) .on('dragleave.wp-uploader, drop.wp-uploader', function() { uploaddiv.removeClass('drag-over'); }); } else { uploaddiv.removeClass('drag-drop'); jQuery('#drag-drop-area2').off('.wp-uploader'); } }); uploader.init(); // a file was added in the queue uploader.bind('FilesAdded', function(up, files) { // var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); plupload.each(files, function(file) { // @codingStandardsIgnoreLine if (!/^backup_([\-0-9]{15})_.*_([0-9a-f]{12})-db([0-9]+)?\.(gz\.crypt)$/i.test(file.name)) { alert(file.name+': '+updraftlion.notdba); uploader.removeFile(file); return; } // a file was added, you may want to update your DOM here... jQuery('#filelist2').append( '\ \
\